VPS使用Nginx开启中转节点 ss/ssr/v2ray流量转发负载均衡的办法 |
您所在的位置:网站首页 › nginx 中转 pip源 › VPS使用Nginx开启中转节点 ss/ssr/v2ray流量转发负载均衡的办法 |
![]() 如果我们要保证所用的所有线路全部都不掉线,那就需要用到负载均衡 我这里介绍就是Nginx方法做负载均衡,可以做到真正的零宕机,宕机秒切换 准备一台VPS或者Nat VPS来做我们的中转机,中转机用的是debian系统 先安装nginx apt-get install nginx -y然后在Nginx的主配置文件内写一个include,需要用到stream段 echo "include /etc/nginx/tcpconf.d/*.conf;" >> /etc/nginx/nginx.conf创建配置文件的目录 mkdir -p /etc/nginx/tcpconf.d新建配置文件 vi /etc/nginx/tcpconf.d/proxy.conf把下面的配置复制到proxy.conf里,upstream的server改成目标的IP和端口,server下面的lisren换成你中转服务器的端口 weight(权重)模式,可以去掉这两个设置让Nginx默认用于轮询模式 stream { upstream tcpssh { server 136.210.178.173:43585 weight=3; server 113.82.116.48:43585 weight=5; } server { listen 58888; listen 58888 udp; proxy_pass tcpssh; } }查看nginx端口 ss -ntlp| grep -i nginxNginx用到的命令 查看状态 systemctl status nginx.service 重启nginx systemctl restart nginx.service 启动nginx systemctl start nginx.service这里v2ray配置参数换成我中转服务器是118.42.35.16 , 端口按照上面lisren端口的58888 简单用一张图来表明具体流程,Nginx 支持三种负载均衡的方式:Round Robin(简单轮询),Least Connections(最少连接) 和 Least Time(最少时间) ![]() |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |